import java.util.Arrays;
import java.util.Stack;

class Solution {
    public boolean isValid(String s) {
        Stack<Character> characterStack = new Stack<>();
        for(int i = 0;i < s.length(); i++) {
            char ch1 = s.charAt(i);
            if(ch1 == '('||ch1 == '{' || ch1 == '[') {
                characterStack.push(ch1);
            } else {
                if(characterStack.empty()) {
                    return false;
                }
                char ch2 = characterStack.peek();
                if(ch2 == '('&&ch1 == ')' ||ch2 == '{'&&ch1 == '}' ||ch2 == '['&&ch1 == ']') {
                    characterStack.pop();
                } else {
                    return false;
                }
            }
        }
        if(characterStack.empty()) {
            return true;
        }
        return false;
    }
    public int maxArea(int[] height) {
        int min = 0;
        int left = 0;
        int right = 0;
        int max = 0;
        for(int i = 0;i < height.length;i++) {
            if(maxliftright(height,i) > max) {
                max = maxliftright(height,i);
            }
        }
        return max;
    }
    public int maxliftright(int[] arr,int cmd) {
        int lh = 0;
        int rh = 0;
        for(int i = cmd; i >= 0; i--) {
            if(arr[i] > arr[cmd]) {
                lh = i;
            }
        }
        lh = arr[cmd] * (cmd - lh);
        for(int i = cmd; i < arr.length; i++) {
            if(arr[i] > arr[cmd]) {
                rh = i;
            }
        }
        rh = arr[cmd] * (rh - cmd);
        return lh > rh ? lh : rh;
    }
}
